home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / misc / biology / logolife.cpt / Logo Life / Logo Life TEXT < prev    next >
Encoding:
Text File  |  1992-07-27  |  21.3 KB  |  514 lines

  1.  
  2. Logo Life
  3.  
  4. By Tim Endres
  5.  
  6. Release 1.0
  7.  
  8.  
  9. Tim Endres, ICE Engineering, Inc.
  10. 8840 Main Street, Whitmore Lake, MI  48189
  11. Internet:  logo@ice.com
  12.  
  13.  
  14. Table Of Contents
  15. Introduction    1
  16. Basics    1
  17. Turtles    1
  18. Turtle Populations    2
  19. Definitions    3
  20. Turles and Logo Expressions    3
  21. Population Window    3
  22. Getting Started    3
  23. Installing Logo Life    3
  24. Running Logo Life    3
  25. The Population Window    4
  26. Evolution    5
  27. Your First Generation    5
  28. Turtle Fitness Selection    5
  29. Population Evolution    5
  30. Turtle Features    6
  31. Turtles And The ClipBoard    6
  32. Zooming In On A Turtle's Figure    6
  33. Doping Turtles    6
  34. Mutating Turtles    7
  35. Printing Turtles    7
  36. Saving Turtles    7
  37. Advanced    8
  38. Genetic Algorithms and Genetic Programming    8
  39. Logo Expressions and Programming    8
  40. Creating Your Own Turtles    9
  41. Further Study    10
  42.  
  43.  
  44. Introduction
  45.  
  46. Logo Life is an application that combines the concepts of Genetic 
  47. Programming and Logo Graphics. From this combination comes a 
  48. fascinating and entertaining hybrid that not only produces stunning 
  49. graphics, but teaches a great deal about programming, genetics, and the 
  50. basic principles of Artificial Life.
  51.  
  52. Logo is the graphical language used frequently to teach the basic principles 
  53. of programming. The concept is very simple ╨ you are in control of a turtle 
  54. that has a pen that can be dropped to draw and lifted to not draw, and you 
  55. are able to give the turtle simple commands to move forward, turn right 
  56. and turn left. With this extremely simple set of instructions, one is capable 
  57. of creating a vast combination of graphical images, and this is 
  58. accomplished with simple algorithms that are recursive in nature.
  59.  
  60. Genetic programming languages are an upshot of the splendid work 
  61. inspired by John Holland involving Genetic Algorithms. John Holland's 
  62. work took a simple example from nature, one of our universe's most 
  63. impressive creations, and applied it to adaptive computer algorithms 
  64. involving search and optimization. Holland's work involved mapping a 
  65. problem representation into a binary string, or chromosome, and using 
  66. genetic and evolutionary principles of fitness proportionate selection for 
  67. reproduction, with random crossover and mutation, to search enormous 
  68. solution spaces efficiently.
  69.  
  70. Genetic programming languages apply the same principles of fitness 
  71. proportionate selection for reproduction and random ccrossover and 
  72. mutation, but the chromosome in this case is an expression tree, not a bit 
  73. string as in traditional GAs. The expression tree in Logo Life is a syntax 
  74. that drives the Logo Turtle. The fitness each logo expression expression is 
  75. determined by you, the driver of Logo Life.
  76.  
  77. You will find that Logo Life is very simple, but has very subtle depths. You 
  78. will also find it difficult to stop evolving new logo turtles! Generation after 
  79. generation. In fact, once you are convinced that Logo Life has nothing more 
  80. to offer, it will astound you with an image you did not anticipate, and a new 
  81. line of creativity will evolve. Enjoy
  82.  
  83. Basics
  84.  
  85. Turtles
  86.  
  87. Logo Life is about turtles. Logo Turtles. Logo turtles are special turtles that 
  88. know how to draw in the sand. They spend long leisurely days on the beach, 
  89. tanning their shells and soaking up rays with their cheap sunglasses on. 
  90. Turtles, being the laid back bunch that they are, will only perform a few 
  91. tricks when it comes to making lines in the sand. In fact, the only tricks 
  92. that these turtles have up their sleeve are:
  93.  
  94. * Turtles can lift their stick (so they make no tracks) or drop their stick (so 
  95. they make tracks)
  96.  
  97. * Turtles can move forward a specific number of steps.
  98.  
  99. * Turtles can turn left and right a specific number of degrees.
  100.  
  101. That's all a poor turtle can do. But don't let them fool you! They can draw 
  102. things you wouldn't believe.
  103.  
  104. In a later chapter we discuss these commands in detail, and describe how 
  105. you can write your own turtle logo programs.
  106.  
  107.  
  108. Turtle Populations
  109.  
  110. Turtles live in small populations, whose number depend upon your screen 
  111. size. Generally the number of turtles in your population is 24. Each turtle in 
  112. the population has its own sand in which to draw.
  113.  
  114. Each turtle will draw its figure in the sand during its lifetime, or in a 
  115. single generation. After each turtle draws its figure, they will display them 
  116. to you, and you will decide which turtles are fit to reproduce for the next 
  117. generation of turtles.
  118.  
  119. Once you have selected the most fit turtles, they will reproduce in a fitness 
  120. proportionate fashion1 (the best turtles randomly mate, while the least fit 
  121. turtles are left out) to create a new population of turtles that will replace the 
  122. older population. As with natural genetics, some of the turtles in the new 
  123. population will be virtually exact duplicates of their parents, while others 
  124. will combine the features of their parents to create a new figure.
  125.  
  126. Generation after generation, you will select the turtles that exhibit the type 
  127. of figure drawing behaviour that you seek, and the population will evolve 
  128. over time to create some of the most fascinating figures you have ever seen, 
  129. and possibly teach you things about the logo programming language you 
  130. had not considered.
  131.  
  132.  
  133. Definitions
  134.  
  135. Turles and Logo Expressions
  136.  
  137. A Logo Life turtle, like its logo counterpart is in actuality a graphical 
  138. cursor. It has a very simple state, namely a coordinate position, a direction 
  139. in which it is pointed, and a stick that is either up or down.
  140.  
  141. The turle's location is quite immaterial, since all of the turtle's commands 
  142. operate in a relative fashion, such as move forward 2 steps. Further, no 
  143. matter how large the turle's figure gets, nor how far it may wander from 
  144. its original starting point, the figure will be scaled and translated to be 
  145. centered within your visual display.
  146.  
  147. The direction in which the turtle is facing is again immaterial from the 
  148. turtle's point of view. Everything that the turtle does is relative to the 
  149. direction it is currently facing. This is why the turtle's language only 
  150. allows for commands like turn right 10 degrees, and does not allow for 
  151. commands such as turn to 48 degrees due north.
  152.  
  153. The one state in which the turtle is most interested is the state of the stick. 
  154. When the stick is down, the turtle is making figures in the sand. When the 
  155. stick is up, the turtle still moves, but does not make any figures in the sand. 
  156.  
  157. Population Window
  158.  
  159. The population window displays a generation of turtles' figures. Each 
  160. turtle's figure is drawn for you in a small square in the Population 
  161. Window. The population window can also display an enlarged view of any 
  162. one of the turtles' figures.
  163.  
  164. The population window is your view of the evolving world of the logo turtles. 
  165. In each successive generation, you will be shown the turtle's figures and 
  166. will determine which turtles will be involved in the evolution of the next 
  167. generation of turtles.
  168.  
  169.  
  170. Getting Started
  171.  
  172. Installing Logo Life
  173.  
  174. To install Logo Life, simply copy the Logo Life folder to your hard disk. You 
  175. do this by dragging the Logo Life folder to your hard disk icon. Once the 
  176. folder is copied to your hard drive, you are ready to go.
  177.  
  178. Running Logo Life
  179.  
  180. Running Logo Life is as simple as installing it. You simply open the Logo 
  181. Life folder that you copied to your hard drive by double clicking on it. Inside 
  182. this folder you will find the Logo Life application. Double click on the Logo 
  183. Life application icon. This will cause the Logo Life program to be lauched 
  184. and the Logo Life menus to be displayed in the menu bar.
  185.  
  186. To begin a new population of Logo Life turtles, you must select the New 
  187. Population item in the File menu. This will open a new population window, 
  188. in which turtles will be randomly created, and each turtle will display its 
  189. figure in a small square.
  190.  
  191. It will take some time, depending on the complexity of each turtle's 
  192. algorithm, to draw all of the figures for the entire population, so please be 
  193. patient while this is done. You may click in other applications during this 
  194. time, and Logo Life will compute the figures in the background.
  195.  
  196.  
  197. The Population Window
  198.  
  199. The Population Window is a non-scrollable, fixed size window which will 
  200. display turtle figures. When a new population is evolved, the window will 
  201. display all of the population's figures in small rectangles arranged in rows 
  202. and columns.
  203.  
  204. You may click on a particular figure to make it's turtle the currently 
  205. selected turtle. The selected turtle is identified by inverting the figure of the 
  206. turtle to distinguish it from the other turtles.
  207.  
  208. A selected turtle may have several operations performed upon it. For 
  209. instance, you may have the turtle's figure blown up to be displayed in the 
  210. full contents of the population window. This allows you to inspect the finer 
  211. details of the turtle's figure. You can also print a turtle's figure, save its 
  212. figure and its corresponding algorithm to a file, or copy a turtle and paste it 
  213. into another turtle's square (competition and survival). You may also dope 
  214. a selected turtle with another turtle's algorithm that was earlier saved to a 
  215. file, and finally, you may mutate a selected turtle to change its algorithm, 
  216. and thus, its figure.
  217.  
  218. Notice that there is a thick lined square outside the figure of all of the 
  219. turtles. This is an indication that this turtle is currently chosen to 
  220. participate in the reproduction of the next generation of turtles. If the thick 
  221. square is not displayed around a turtle, then it will not be chosen for 
  222. reproduction to create the next generation of turtles.
  223.  
  224. You can chose all turtles for participation in the next generation using the 
  225. Chose All Turtles command in the File menu. You may chose none of the 
  226. turtles for participation in the next generation by selecting the Chose No 
  227. Turtles command in the File menu.
  228.  
  229.  
  230. Evolution
  231.  
  232. Your First Generation
  233.  
  234. When your first generation of turtles is displayed, you may notice that 
  235. overall the figures are not that impressive. This is, of course, to be expected, 
  236. since the turtles are created in a completely random fashion. In fact, if any 
  237. of the turtles shows any signs of interesting behaviour, this is merely a low 
  238. probability event and should be considered a blessing.
  239.  
  240. However, do not be discouraged. As you begin to selectively choose turtles 
  241. for reproduction and evolution, you will see dramatic jumps in the level of 
  242. sophistication of your turtles. For each new generation of turtles does not 
  243. have to re-learn the complexities of their parents, they are fortunate enough 
  244. to inherit them from the genetic constituency of their parents. In fact, as 
  245. new figures appear in succeeding generations, you will begin to notice the 
  246. parts that they inherited from their parents, and even begin to identify 
  247. different turtles as being siblings!
  248.  
  249. Once you have evaluated the figures of your first generation of turtles, you 
  250. will certainly wish to evolve a new generation of turtles to see the 
  251. evolutionary process in full swing. But first, you must decide which turtles 
  252. will be fortunate enough to participate in the reproduction of this new 
  253. generation of more elite figure drawing turtles.
  254.  
  255. Turtle Fitness Selection
  256.  
  257. Before evolving a new generation of turtles, it is beneficial to select only the 
  258. turtles you are interested in persuing. If you were to simply allow all of the 
  259. turtles to evolve equally, then the population as a whole would simply 
  260. wander genetically, with a low probability of producing any particular type 
  261. of order upon the algorithms that define how the turtles actually draw their 
  262. figures. Thus, you must select those that you wish to persue and those that 
  263. you do not. This allows you to focus in on particular traits in the turtles, 
  264. and to persue these traits in successive generations.
  265.  
  266. You may change the fitness of a turtle for reproduction by using an option-
  267. click. Clicking on a turtle's figure while holding down the option key will 
  268. causing the turtle's fitness to be toggled. Thus, if the turtle was originally 
  269. fit (had a thick square around its figure) it will be made unfit and will not be 
  270. selected for reproduction. Accordingly, if the turtle was originally unfit (did 
  271. not have a thick square around its figure), then it would be identified as fit 
  272. and the thick square border drawn around it.
  273.  
  274. Population Evolution
  275.  
  276. Once you have chosen the turtles that are fit to be reproduced, you can 
  277. evolve your next generation of turtles. To accomplish this task, select the 
  278. Evolve Population item in the File menu.
  279.  
  280. This command will clear the population window's display, evolve the next 
  281. generation of turtles, and begin displaying their figures in their respective 
  282. squares. Again, the amount of time needed to perform this drawing 
  283. depends upon the complexity of each turtle's algorithm.
  284.  
  285.  
  286. Turtle Features
  287.  
  288. Turtles And The ClipBoard
  289.  
  290. You may copy and paste turtles to and from the clipboard just like any other 
  291. Macintosh data. When a turtle is copied to the clipboard, using the 
  292. Copy╩command in the Edit menu, both textual and graphical data are 
  293. placed on the clipboard.
  294.  
  295. The textual data (data type TEXT) will contain the logo algorithm used by 
  296. the turtle to draw its figure. This data can then be pasted into any text 
  297. editor, or other application that utilizes text. Further, this textual data may 
  298. be pasted back into any selected turtle to replace its algorithm (and thus 
  299. figure) with that represented by the algorithm on the clipboard.
  300.  
  301. The graphical data contains a standard Macintosh picture (data type PICT) 
  302. that can be pasted into any application that accepts PICT data. This allows 
  303. you to paste a turtle's figure into graphical documents and as figures in 
  304. textual documents.
  305.  
  306. Zooming In On A Turtle's Figure
  307.  
  308. To display a turtle's figure in the full area of the population window (to blow 
  309. it up), sinply double click on the turtle's figure, or select the turtle's figure 
  310. by clicking on it once, and select the Zoom Selection command in the File 
  311. menu.
  312.  
  313. This will cause the turtle to display its figure full size in the contents of the 
  314. population window. To return to viewing the entire population, simply click 
  315. anywhere within the contents of the window, and the entire population will 
  316. be displayed once again.
  317.  
  318. Doping Turtles
  319.  
  320. Doping a turtle means to replace its algorithm with another. This causes 
  321. the turtle to display a figure that you select. This can be accomplished with 
  322. the algorithm from a previously saved turtle, or it could be an algorithm 
  323. that you have copied and modified, or it could be an algorithm that you have 
  324. manufactured yourself using the Logo language.
  325.  
  326. Doping a turtle from a previously saved turtle is accomplished via the Dope 
  327. Selection command in the File menu. This command is only highlighted 
  328. when a turtle is selected. When you select the command, the Standard Get 
  329. File Dialog will be displayed asking you to select a file which contains a 
  330. previously saved turtle. Once you select a file, this file's turtle algorithm 
  331. will replace the algorithm of the selected turtle, and the new figure will be 
  332. drawn in the selected turtle's square.
  333.  
  334. Doping a turtle from an algorithm in textual form is accomplished via the 
  335. Paste command in the Edit menu. When the Paste command is selected, it 
  336. will look on the Macintosh Clipboard for textual data (data type TEXT). If 
  337. textual data is found, it is assumed to be an expression using the logo 
  338. language. If this turns out to be true, and the algorithm is syntactically 
  339. correct (meaning there are no mistakes in the expression), then the 
  340. currently selected turtle will have its algorithm replaced with the 
  341. algorithm from the clipboard and a new figure will be drawn for the turtle.
  342.  
  343. Mutating Turtles
  344.  
  345. Mutating turtles involves randomly generating a logo expression and then 
  346. randomly splicing this expression into the algorithm of the turtle. This can 
  347. have a wide range of effects, from no visual difference, to profound visual 
  348. change including no display at all.
  349.  
  350. Mutating a turtle is accomplished by selecting the turtle's figure, then 
  351. selecting the Mutate Selection item in the File menu. This will cause the 
  352. mutation to be made to the selected turtle, and its new figure to be displayed 
  353. in its square.
  354.  
  355. Mutation is usually used when a population appears to be stuck in a 
  356. particular feature set and it is proving difficult to move the population into 
  357. any new directions without the injection of some random figures.
  358.  
  359.  
  360. Printing Turtles
  361.  
  362. You may print a turtle's figure to any Apple supported printer. This is done 
  363. by selecting the desired turtle's figure and selecting the Print Selection 
  364. command from the File menu.
  365.  
  366. For laser printers, Logo Life will include the QuickDraw Picture Comment 
  367. that causes the printer to draw lines as thinly as possible. This will improve 
  368. the resolution of your printed figures to whatever is available from the 
  369. printer.
  370.  
  371. Saving Turtles
  372.  
  373. You may save turtles to a file. This will cause two things to be saved. In the 
  374. data fork of the file, the text that represents the logo algorithm used to draw 
  375. the turtle's figure will be saved. This allows you to use any TEXT editor 
  376. available to you to view the turtle's algorithm. You may even modify the 
  377. algorithm to create new figures, or to improve upon an existing figure.
  378.  
  379. In the resource fork of the turtle file (where dialogs and such are stored), 
  380. the picture (data type PICT) that represents the turtle's figure will be 
  381. stored. This allows you to open the figure and paste it into applications that 
  382. are able to use the PICT data, such as graphics programs.
  383.  
  384.  
  385. Advanced
  386.  
  387. Genetic Algorithms and Genetic Programming
  388.  
  389. Genetic algorithms are fast becoming a hot area of computer science 
  390. research. Propelled into popularity by the pioneering work of John Holland 
  391. at the University of Michigan in the 1970's, genetic algorithms have been 
  392. successfully utilized in problem areas previously thought intractible.
  393. The concept of genetic algorithms is very simple. A problem is mapped into 
  394. a chromosome expression and the principals of fitness proportionate 
  395. selection and crossover mating are implemented to successively evolve 
  396. populations of proposed solutions that over time evolve to an acceptable 
  397. solution to a problem.
  398.  
  399. Genetic programming takes the genetic algorithm one step further, by 
  400. mapping the problem such that we are looking for an algorithm. The 
  401. desired algorithm is then evolved by generating random algorithms and 
  402. successively reproducing them using the genetic principles of fitness 
  403. proportionate selection and crossover mating.
  404.  
  405. The advantage of evolving logo algorithms is that the results are visual and 
  406. can show inheritence is a striking way. This allows a student of genetic 
  407. algorithms to get a visual sense of how the algorithms evolve over time, and 
  408. in what ways they evolve.
  409.  
  410.  
  411. Logo Expressions and Programming
  412.  
  413. Logo is a graphical programming language. It has been around for many 
  414. years, and is currently popular for teaching simple programming 
  415. principles to students. It is exceptionally good for this task, since the 
  416. concept of the turtle is much easier to grasp than that of a CPU, and the 
  417. results of the programs are visual, providing good feedback and motivation.
  418. Logo Life takes the logo language and reduces it to an extremely simple 
  419. subset. The reasons for this are many, but the primary reason is that the 
  420. reduction is required to make the genetic algorithm feasible.
  421.  
  422. The Logo Life programming language can be most simple summed up in 
  423. the following manner:
  424. algorithm    =>    expr
  425. expr        =>    ( terminal )
  426.             or
  427.             ( function expr_list )
  428. expr_list    =>    expr ...
  429.  
  430. terminal    =>    One of the following:
  431.  
  432. FWD_1, FWD_2, FWD_3, FWD_5, FWD_10, 
  433. FWD_50, FWD_100
  434. These commands move the turtle the number of specified 
  435. steps forward from its current position in the direction it is 
  436. facing. If its stick is down, drawing occurs as the turtle 
  437. moves.
  438.  
  439. LEFT_1, LEFT_2, LEFT_3, LEFT_5, LEFT_10, 
  440. LEFT_15, LEFT_45, LEFT_90
  441. These commands turn the turtle the specified number of 
  442. degrees to the left from its current direction. 
  443.  
  444. RIGHT_1, RIGHT_2, RIGHT_3, RIGHT_5, RIGHT_10, 
  445. RIGHT_15, RIGHT_45, RIGHT_90
  446. These commands turn the turtle the specified number of 
  447. degrees to the right from its current direction. 
  448.  
  449. function    =>    One of the following:
  450.  
  451. BLOCK
  452. This command executes the expressions in its expression 
  453. list. 
  454.  
  455. REPEAT_2, REPEAT_3, REPEAT_5, REPEAT_10, 
  456. REPEAT_50, REPEAT_100
  457. These commands repeat the expressions in their expression 
  458. list the specified number of times. 
  459.  
  460. IF_PEN_UP, IF_PEN_DOWN
  461. These two commands execute the first expression in their 
  462. expression list if true, otherwise they ecxecute the second 
  463. expression.
  464.  
  465.  
  466. Creating Your Own Turtles
  467.  
  468. You can use any Macintosh text editor to create a turtle logo expression and 
  469. paste the expression into a population to help with its evolution, or to 
  470. explore new evolutionary paths.
  471.  
  472. For example, you might type in the following program and paste it into a 
  473. turtle's square that you select in a population window:
  474.  
  475. ( REPEAT_2 ( REPEAT_2 ( FWD_100 ) (RIGHT_90 ) ) )
  476.  
  477. The logo expression above would draw a square with sides 100 steps long. 
  478. You might also try this expression:
  479.  
  480. ( REPEAT_5
  481. ( FWD_100 )
  482. ( RIGHT_45 )
  483. ( RIGHT_5 )
  484. ( RIGHT_10 )
  485. ( RIGHT_10 )
  486. ( RIGHT_2 )
  487. )
  488.  
  489. Or you might try this one:
  490.  
  491. ( REPEAT_100
  492. ( FWD_100 )
  493. ( RIGHT_90 )
  494. ( RIGHT_10 )
  495. ( RIGHT_10 )
  496. ( RIGHT_5 )
  497. ( RIGHT_3 )
  498. )
  499.  
  500. Further Study
  501.  
  502. There are many good books on both logo and genetic algorithms.
  503. The following books have proved useful for me:
  504.  
  505. Turtle Geometry by Harold Abelson and Andrea A. diSessa. Published by 
  506. The MIT Press, Cambridge, Massachusetts. ISBN 0-262-01063-1.
  507.  
  508. Adaptation In Natural And Artificial Systems by John Holland. Published 
  509. by The MIT Press, Cambridge, Massachusetts. ISBN 0-262-58111-6.
  510.  
  511. Genetic Algorithms in Search, Optimization and Machine Learning by 
  512. David Goldberg. Published by Addison Wesley, Rading, Massachusetts. 
  513. ISBN 0-201-15767-5.
  514.